import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.stereotype.Component;

public class Demo {
    public static void main(String[] args) throws Exception {
        Person p = new Person();
        p.sayHello();

        Class cls = Class.forName("demo1.Person"); // 修改了此处的类名
        Person p2 = (Person) cls.newInstance();
        p2.sayHello();

        // 通过 spring 容器获取对象
        AnnotationConfigApplicationContext context
                = new AnnotationConfigApplicationContext("demo1");
        Person p3 = context.getBean(Person.class);
        p3.sayHello();

    }
}